<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
	<head>
		<base th:href="@{/}"/>
		<meta charset="utf-8">
		<title>查询版块页面</title>
		<link rel="stylesheet" href="../css/bootstrap.min.css"/>
		<script src="../js/jquery.min.js"></script>
		<script type="text/javascript" th:inline="javascript">
		function deleteType(tid){
			$.ajax({
				//请求路径，要注意url和inline
				url:[[@{/type/deleteType}]],
				//请求类型
				"post",
				//data表示发送的数据
				data:{
					tid
				},
				//成功响应的结果
				success:function(obj){
					if(obj=="no"){
						alert("版块下有帖子不允许删除!");
					}else{
						if(window.confirm("真的删除该版块吗?")){
							//获取路径
							var pathName = window.document.location.pathname;
							//截取，得到项目名称
							var projectName = pathName.substring(0,pathName.substr(1).indexOf('/')+1);
							window.location.href = projectName + obj;
						}
					}
				},
				error : function(){
					alert("处理异常!");
				}
			})
		}
		</script>
	</head>
	<body>
		<br><br><br>
		<div class="container">
			<div class="panel panel-primary">
				
				<div class="panel-heading">
					<h3 class="panel-title">版块列表</h3>
				</div>
				
				<div class="panel-body">
					<div class="table table-responsive">
						<table class="table table-bordered table-hover">
							<tbody class="text-center">
								<tr>
									<th>版块ID</th>
									<th>版块名称</th>
									<th>操作</th>
								</tr>
								<tr th:each="gty:${allTypes}">
									<td th:text="${gty.id}"></td>
									<td th:text="${gty.typename}"></td>
									<td>
										<a th:href="javascript:deleteType(' + ${gty.id} + ')">删除</a>
									</td>
								</tr>
								<tr>
									<td colspan="3" align="right">
										<ul class="pagination">
											<li><a>第<span th:text="${currentPage}"></span>页</a></li>
											<li><a>共<span th:text="${totalPage}"></span>页</a></li>
											<li>
												<span th:if="${currentPage}!=1"><a th:href="'type/selectAllTypeByPage?currentPage = ' + ${currentPage - 1}">上一页</a></span>
												<span th:if="${currentPage}!=${totalPage}"><a th:href="'type/selectAllTypeByPage?currentPage = ' + ${currentPage + 1}">下一页</a></span>
											</li>
										</ul>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div>
			</div>
		</div>
	</body>
</html>
